// pages/hisBusStas/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isShow:true,
    tabIndex:1,
    startDate:'2020-01-11',
    endDate:'2020-03-23',
    today:'',
    weekLastDay:'',
    monthLastDay:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var oneDay = 24 * 3600 * 1000;
    var date = new Date()
    let today = this.formatDay(date)
    let weekLastDay = this.formatDay(date-oneDay*7)
    let monthLastDay = this.formatDay(date-oneDay*30)
    this.setData({
      today,
      weekLastDay,
      monthLastDay
    })
  },
  formatDay(cellValue) {
    var date=cellValue?new Date(cellValue):new Date() 
    var year = date.getFullYear()
    var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
    var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() 
    return year + '-' + month + '-' + day
  },
  goSearchList(){
    //快速搜索
    console.log('开始日期: '+this.data.startDate)
    console.log('结束日期: '+this.data.endDate)
    wx.navigateTo({
      url: '../hisBusList/index',
    })
  },
  bindStartDateChange: function(e) {
    this.setData({
      startDate: e.detail.value
    })
  },
  bindEndDateChange: function(e) {
    this.setData({
      endDate: e.detail.value
    })
  },
  //关闭/打开 弹框
  changeShow(event){
    var dataset=event.currentTarget.dataset
    this.setData({
      isShow:dataset.val
    })
  },
  changeTab(event){
    var dataset=event.currentTarget.dataset
    this.setData({
      tabIndex:dataset.val
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})